package com.healthshare.parse.news;

import java.util.ArrayList;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.palmedia.framework.parse.BaseParse;




/**
 * @author xudeliang
 * 二级分类解析
 */
public class NewsListParse extends BaseParse
{

	//新闻列表类型，辅助使用
	public String type = "";
	
	public ArrayList<NewsLisItem> newsLisItems = new ArrayList<NewsLisItem>();
	public NewsListParse()
	{
		
	}
	
	
	@Override
	public boolean Parse(byte[]data)
	{
		boolean ret = super.Parse(data);
		if(!ret)
		{
			return false;
		}
		if(JSON==parseType)
		{
			try 
			{
				JSONArray ja = jsonObject.getJSONArray("columlist");
				int len = ja.length();
				for(int i=0;i<len;i++)
				{
					JSONObject iobject =ja.getJSONObject(i);
					String id = iobject.getString("id");
					String title = iobject.getString("title");
					NewsLisItem kv = new NewsLisItem();
					kv.id = id;
					kv.title = title;
					newsLisItems.add(kv);
				}
				return true;
			} 
			catch (JSONException e) 
			{
				e.printStackTrace();
			}
		}
		return false;
	}
	
	public class NewsLisItem
	{
		public String id;
		public String title;
		
	}
	
}
